Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sw: Fix RAM boot detection #331

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

michalsieron
Copy link

Up until now, docs said that RAM boot happens, when foboot finds 0x17ab0f23 in first 56 bytes of loaded binary.

That wasn't the case, it was checking only first 12 bytes.
for loop did at most (max_check/4)-1 iterations, which is equal to 15, because max_check has the value of rx_buffer size from usb-dev.c, which is 64 bytes.

15 times 4 byte words results in 60 checked bytes, but there was also division by 4 when accessing items of dfu_buffer, which reduced number of checks to 3 resulting in 12 bytes checked.

I also corrected the docs from 56 checked bytes to 60.

Up until now, docs said that RAM boot happens, when foboot finds
`0x17ab0f23` in first 56 bytes of loaded binary.

That wasn't the case, it was checking only first 12 bytes.
`for` loop did at most `(max_check/4)-1` iterations, which is equal to 15,
because `max_check` has the value of `rx_buffer` size from usb-dev.c.

15 times 4 byte words results in 60 checked bytes, but there was also
division by 4 when accessing items of `dfu_buffer`, which reduced number
of checks to 3.

I also corrected the docs from 56 checked bytes to 60.
@mithro mithro requested a review from xobs March 17, 2022 15:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant